<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.util.*,Entity.*,Biz.*,javax.persistence.*"
    pageEncoding="UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <html>

        <head>
            <!--Import Google Icon Font-->
            <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
            <!--Import materialize.css-->
            <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection" />

            <!--Let browser know website is optimized for mobile-->
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>核酸结果上传界面</title>
        </head>
        <script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>

        <body>
            <script type="text/javascript">
                $(document).ready(function () {
                    $('select').material_select();
                });
            </script>

            <% 
            	userBeanLocal _userBean=(userBeanLocal)session.getAttribute("_userBeanLocal"); 
            	User user=_userBean.getUser(); 
            	EntityManagerFactory
                factory=Persistence.createEntityManagerFactory("PCR_System",null); 
            	EntityManager manager=factory.createEntityManager(); 
                EntityTransaction transaction=manager.getTransaction();
                transaction.begin(); 
                Query q=manager.createQuery("FROM PcrTube p"); 
                List tubes=q.getResultList();
                request.setAttribute("tubes", tubes); 
                transaction.commit(); 
                manager.close(); 
                factory.close(); 
            %>



                <div class="container">
                    <div class="row">
                        <table>
                            <thead>
                                <tr>
                                    <th data-field="id">试管编号</th>
                                    <th data-field="status">状态</th>
                                    <th data-field="collect_time">采样时间</th>
                                    <th data-field="result_time">结果时间</th>
                                    <th data-field="users">被检测者</th>
                                </tr>
                            </thead>

                            <tbody>
                                <c:forEach items="${tubes}" var="tube">
                                    <tr>
                                        <td>${tube.id}</td>
                                        <td>
                                        ${tube.status}
                                            <c:if test="${tube.status eq 'no_result'} ">无结果</c:if>
                                            <c:if test="${tube.status eq 'negative'} ">阴性</c:if>
                                            <c:if test="${tube.status eq 'positive'} ">阳性</c:if>
									    </td>
                                        <td>${tube.collect_time}</td>
                                        <td>${tube.result_time}</td>
                                        <td>${tube.users}</td>
                                    </tr>
                                </c:forEach>

                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <form action="updateTubeServlet" method="get">
                            <div class="input-field col l3">
                                <input id="tube_ID" name="tube_ID" type="text" class="validate" required="required">
                                <label for="tube_ID">试管编号：</label>
                            </div>
                            <div class="input-field col l4">
                                <select name="result">
                                    <option value="" disabled selected>请选择</option>
                                    <option value="negative">阴性</option>
                                    <option value="positive">阳性</option>
                                </select>
                                <label>结果</label>
                            </div>

                            <div class="col l2 valign-wrapper">
                                <a class="valign">
									<button class="waves-effect waves-light btn valign"  type="submit">提交</button>
                                </a>
                            </div>
                        </form>
                    </div>
                </div>
                <!--Import jQuery before materialize.js-->
                <script type="text/javascript" src="js/materialize.min.js"></script>
        </body>

        </html>